<?php


namespace app\api\controller;
use think\DB;
class Yyxj
{

    public function Yxj(){
        {
            $id = input('id');
            if(!$id){
                return 0;
            }//判断有无参数
            //$id =  $this->requert->has('id');
            //进行数据库查询nav
            $data = Db::name('banner ba')
                ->join('attachment b', 'ba.thumb=b.id')
                ->join('fenlei f', 'ba.fenlei_id=f.id')
                ->field('ba.id,b.filepath')
                //->where('fenlei_id',3)
                ->where('f.id',$id)
                ->select();
            foreach ($data as $key => &$v) {
                $v['filepath'] = 'http://' . $_SERVER['HTTP_HOST'] . $v['filepath'];
            }
            if ($data) {
                return json(['code' => 200, 'msg' => "成功", 'data' => $data]);
            } else {
                return json(['code' => 0, 'msg' => "失败", 'data' => []]);
            }
        }
    }
}